package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.IUnusualFeedBackForLogisticsCargoView;
import com.cloudsigns.factorymanager2.engineering.model.IUnusualFeedBackForLogisticsCargoModel;
import com.cloudsigns.factorymanager2.engineering.model.UnusualFeedBackForLogisticsCargoModel;

/**
 * Created by tony on 2018/4/20.
 */

public class UnusualFeedBackForLogisticsCargoPrsenter {
    private IUnusualFeedBackForLogisticsCargoView view;
    private IUnusualFeedBackForLogisticsCargoModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public UnusualFeedBackForLogisticsCargoPrsenter(IUnusualFeedBackForLogisticsCargoView view) {
        this.view = view;
        this.model = new UnusualFeedBackForLogisticsCargoModel();
    }

    public void submitUnusualFeedBackForLogisticsCargo() {


        model.submitUnusualFeedBackForLogisticsCargo(view.getAdvice(), view.getId(), view.getItemId(), view.getOmitContent(), view.getOmitNumber(), view.getType(), view.getUnusualDays(), new UnusualFeedBackForLogisticsCargoModel.OnUnusualFeedBackForLogisticsCargoListener() {
            @Override
            public void submitUnusualFeedBackForrLogisticsCargoSunccessed() {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.submitUnusualFeedBackForLogisticsCargoSuccessed();
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void submitUnusualFeedBackForrLogisticsCargoFailed(final String desc) {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.submitUnusualFeedBackForLogisticsCargoFailed(desc);
                        view.hideLoading();
                    }
                });
            }
        });

    }
}
